﻿using System;
using System.Globalization;
using Windows.UI.Xaml.Data;

namespace BuddyTracker.ViewModel.Helpers
{
    /// <summary>
    /// Binding RadioButton to Integer!
    /// </summary>
    public class RadioButtonToIntConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string s)
        {
            var para = System.Convert.ToInt32(parameter, CultureInfo.InvariantCulture);
            var myChoice = System.Convert.ToInt32(value, CultureInfo.InvariantCulture);
            return para == myChoice;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string s)
        {
            var para = System.Convert.ToInt32(parameter, CultureInfo.InvariantCulture);
            var isChecked = System.Convert.ToBoolean(value, CultureInfo.InvariantCulture);
            return isChecked ? para : -1;
        }
    }
}
